// 触发函数后，在单位时间内不再触发，才会执行函数
function throttle(fn, delay) {
  let timer = null  
  return function (...args) {
    if(timer) {
      clearTimeout(timer)
      timer = null
    }
    const that = this
    timer = setTimeout(() => {
      fn.apply(fn, args)
    }, delay)
  }
}